package com.aiju.cash.ui.multiple_shops.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.aiju.cash.R;

/**
 * 无数据展示页
 * Created by Administrator on 2017/6/13.
 */

public class NoDataView extends RelativeLayout {
    private ImageView imageView;
    private TextView textView;

    public NoDataView(Context context) {
        super(context);
        initView(context);
    }

    public NoDataView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public NoDataView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    void initView(Context context) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.layout_no_data, this);
        imageView = (ImageView) inflate.findViewById(R.id.no_data_iv);
        textView = (TextView) inflate.findViewById(R.id.no_data_tv);
        defaultShow();
    }

    /**
     * 替换图片
     */
    public void replaceIamgeView(int resId) {
        imageView.setImageResource(resId);
    }


    /**
     * 替换文字
     */
    public void replaceTextView(String text) {
        textView.setText(text);
    }


    /**
     * 替换图片和文字
     */
    public void replaceIamgeViewAndtextView(int resId, String text) {
        imageView.setImageResource(resId);
        textView.setText(text);
    }

    /**
     * app默认展示元素
     */
    private void defaultShow() {
        replaceIamgeViewAndtextView(R.mipmap.icon_no_data, "");
    }
}
